#include "stdafx.h"
#include "ZReadWriteLock.h"

CHBAutoReadLock::CHBAutoReadLock( const QReadWriteLock& locker )
	: m_locker(locker)
{
	QReadWriteLock& lock = const_cast<QReadWriteLock&>(m_locker);
	lock.lockForRead();
}

CHBAutoReadLock::~CHBAutoReadLock()
{
	QReadWriteLock& lock = const_cast<QReadWriteLock&>(m_locker);
	lock.unlock();
}

CHBAutoWriteLock::CHBAutoWriteLock( const QReadWriteLock& locker )
	: m_locker(locker)
{
	QReadWriteLock& lock = const_cast<QReadWriteLock&>(m_locker);
	lock.lockForWrite();
}

CHBAutoWriteLock::~CHBAutoWriteLock()
{
	QReadWriteLock& lock = const_cast<QReadWriteLock&>(m_locker);
	lock.unlock();
}